﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MapComponentSprite
{
   public class FlagTextSprite:ImageTextSprite
    {
       /// <summary>
       /// 旗子文字模板绘制对象缓存
       /// </summary>
       public static Dictionary<string,Texture2D> FTexture2Ds=new Dictionary<string, Texture2D>(); //模板文字较少，实例较多
       public FlagTextSprite(string text)
           : base(text)
       {
           this.Font = new System.Drawing.Font("方正北魏楷书繁体", 30f);
           this.Color = new Color(1f, 1f, 1f);
           if (FTexture2Ds.ContainsKey(text))
               this.Image = FTexture2Ds[text];
           else
           {
               Texture2D td = CreateTextTexture(text);
               FTexture2Ds.Add(text,td);
               this.Image = td;
           }
       }
       public override void Draw(GameTime gameTime)
        {
            SpriteBatch.Draw(this.Image, DrawPosition, null, this.Color);
        }

        public void Update(GameTime gameTime, Rectangle re)
        {
            Rectangle rectangle =new Rectangle(re.X,re.Y,0,0);
            rectangle.X += (int)(re.Width * 0.2);
            rectangle.Y += (int)(re.Height * 0.54);
            rectangle.Width = (int)(re.Width * 0.5);
            rectangle.Height = (int)(re.Height * 0.4);
            this.DrawPosition = rectangle;
        }

      
    }
}
